#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<stdlib.h>
int main()
{
    pid_t id = fork();
    if(id < 0)
    {
        perror("fork");
        return 0;
    }
    if(id == 0)
    {
        printf("i am child process pid: %d, ppid:%d\n", getpid(), getppid());
        execl("/usr/bin/ls","ls","-a","-l",NULL);
        exit(1);
    }
    else if(id > 0)
    {       
        pid_t ret = waitpid(id, NULL, 0);
        if(ret > 0)
        {
            printf("wait success, parentpid: %d, child: %d\n", getpid(), ret);
        }
    }
    return 0;
}
